// 安装第三方库Fabrice Weinberg/NTPClient
#include <Arduino.h>
#include <NTPClient.h>
#include <ESP8266WiFi.h>
#include <WiFiUdp.h>

const char *ssid = "我是wifi";
const char *password = "19900625";

WiFiUDP ntpUDP;
NTPClient timeClient(ntpUDP);

void setup()
{
    Serial.begin(9600);

    WiFi.begin(ssid, password);

    while (WiFi.status() != WL_CONNECTED)
    {
        delay(500);
        Serial.print(".");
    }

    timeClient.begin();
    timeClient.setTimeOffset(28800); //8*3600   北京时间，东八区
}

void loop()
{
    timeClient.update();
    Serial.println(timeClient.getFormattedTime());
    delay(1000);
}